/**  
 * @Title: eee.java
 * @Description: TODO(描述)
 * @author liuyi
 * @date 2023-11-24 15:03:04 
 */  
package com.fsxgt.datagrid.sys.utils;

import java.util.List;

import javax.annotation.PostConstruct;

import org.apache.ibatis.session.SqlSessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.context.annotation.Configuration;

import lombok.RequiredArgsConstructor;

@Configuration
@ConditionalOnBean({SqlSessionFactory.class})
@RequiredArgsConstructor(onConstructor_ = {@Autowired})
public class MybatisInterceptorConfig {
 
    private final List<SqlSessionFactory> sqlSessionFactories;
 
    @PostConstruct
    public void addPageInterceptor() {
    	UserParametersInterceptor userParametersInterceptor = new UserParametersInterceptor();
        for (SqlSessionFactory sqlSessionFactory : sqlSessionFactories) {
            sqlSessionFactory.getConfiguration().addInterceptor(userParametersInterceptor);
        }
    }
 
}
